import Vue from 'vue'
import App from './App'
import router from './libs/router'
import md5 from 'md5'

//图片地址
Vue.prototype.imgSrcUrl='';

//通用组件
import '@/libs/components';

Vue.config.productionTip = false;
Vue.prototype.md5=md5;

//mint-ui
import 'mint-ui/lib/style.css';
import { Picker,Toast } from 'mint-ui';
Vue.component(Picker.name,Picker);
window['Toast']=Toast;

//swiper
import VueAwesomeSwiper from 'vue-awesome-swiper';
import 'swiper/dist/css/swiper.css';
Vue.use(VueAwesomeSwiper, );

//接口
import axios from 'axios';

Vue.prototype.axios=axios;
Vue.prototype.axios.defaults.withCredentials = true;

import api from '@/libs/api';
import http from '@/axios/http';

Vue.prototype.api=api;
Vue.prototype.http=http;
Vue.prototype.loading = true;

//下拉加载更多
Vue.directive('viewmore', {
  bind: (el, binding) => {
    el.addEventListener('scroll', () => {
      if (el.scrollTop + el.offsetHeight >= el.scrollHeight) {
        binding.value();
      }
    }, false)
  }
});

let u = navigator.userAgent;
let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1;
let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
function isUa(){
  if(isiOS){
    return 'ios';
  }else if(isAndroid){
    return 'android';
  }else{
    return 'web';
  }
};

Vue.prototype.isUa=isUa();

//微信sdk
import wxSdk from 'weixin-js-sdk';
Vue.prototype.wxSdk=wxSdk;

//VUEX
import store from '@/vuex';

//页面跳转后执行
router.afterEach((to) => {
  document.title=to.meta.title;
  document.body.scrollTop = document.documentElement.scrollTop=0;
});

new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>',
  store
});
